# a script that compiles the results of Monte Carlo runs stored in structure arrays in multiple batches, creating one sample for each variable at each yearly interval; for each sample, it calculates the average (arithmetic mean - the baseline estimate) and standard deviation, runs normality tests and calculates the percent deviaion of the alternative estimate from the baseline estimate
# version: Sep 2020
# ENSURE that Octave can find the script, use the "addpath" command: addpath ("/[insert the path to your Octave folder]/Octave")

# enter year 0 (2005 <= y0 <= 2014) and year 1 (2006 <= y1 <= 2015)
year = input ("enter year 0: ")
y0 = num2str (year);
year = input ("enter year 1: ")
y1 = num2str (year);
# define file name to load the results of Monte Carlo runs
# ATTENTION: define variable "filename1" because "filename" is already saved in the batches to be loaded; this avoids overwriting "filename"
filename1 = ["/[insert the path to the output Octave files, produced by the "KORUS_r" script]/KORUS_r_" y0 "-" y1 "_batch"];

# confirm the number of batches; the default number is 20
Nofbatches = input (["Are there 20 batches with data structures? (y/n) "], "s");
if (Nofbatches == "n")
	NB = input ("enter the correct number of batches : ");
elseif (Nofbatches == "y")
	NB = 20;
else
	error ("please call the script again and re-enter the correct number of batches")
endif

# print a message about the progress in the execution of the script (optional)
printf ("Starting to extract data from file batches that store the results of Monte Carlo runs.\n")

# extract data, consolidate all batches; N - batch identifier
for N = 1:NB
	filebatch = [filename1 num2str(N)];
	load (filebatch)
# start loop to handle structure fields, F - field identifier
	for F = 1:20
		runname = ["run", num2str(F)];
		allname = ["run", num2str(20*(N-1)+F)];
# country identifiers: r - partner (country of origin), s - importer/home (country in focus)
		for s = [19,36]
			for r = [36,19]
# ignore a case where r = s
				if (r != s)

# ADDITIVE decomposition

					ALLdv.TC.AF.(["r",num2str(r),"_s",num2str(s)]).(allname) = dv.TC.AF.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLdv.TDin.AF.(["r",num2str(r),"_s",num2str(s)]).(allname) = dv.TDin.AF.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLdv.TDout.AF.(["r",num2str(r),"_s",num2str(s)]).(allname) = dv.TDout.AF.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLdv.TR.AF.(["r",num2str(r),"_s",num2str(s)]).(allname) = dv.TR.AF.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLde.TC.AF.(["r",num2str(r),"_s",num2str(s)]).(allname) = de.TC.AF.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLde.TDin.AF.(["r",num2str(r),"_s",num2str(s)]).(allname) = de.TDin.AF.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLde.TDout.AF.(["r",num2str(r),"_s",num2str(s)]).(allname) = de.TDout.AF.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLde.TR.AF.(["r",num2str(r),"_s",num2str(s)]).(allname) = de.TR.AF.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLdy.TC.AF.(["r",num2str(r),"_s",num2str(s)]).(allname) = dy.TC.AF.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLdy.TDin.AF.(["r",num2str(r),"_s",num2str(s)]).(allname) = dy.TDin.AF.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLdy.TDout.AF.(["r",num2str(r),"_s",num2str(s)]).(allname) = dy.TDout.AF.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLdy.TR.AF.(["r",num2str(r),"_s",num2str(s)]).(allname) = dy.TR.AF.(["r",num2str(r),"_s",num2str(s)]).(runname);

					ALLdv.TC.A.(["r",num2str(r),"_s",num2str(s)]).(allname) = dv.TC.A.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLdv.TDin.A.(["r",num2str(r),"_s",num2str(s)]).(allname) = dv.TDin.A.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLdv.TDout.A.(["r",num2str(r),"_s",num2str(s)]).(allname) = dv.TDout.A.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLdv.TR.A.(["r",num2str(r),"_s",num2str(s)]).(allname) = dv.TR.A.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLde.TC.A.(["r",num2str(r),"_s",num2str(s)]).(allname) = de.TC.A.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLde.TDin.A.(["r",num2str(r),"_s",num2str(s)]).(allname) = de.TDin.A.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLde.TDout.A.(["r",num2str(r),"_s",num2str(s)]).(allname) = de.TDout.A.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLde.TR.A.(["r",num2str(r),"_s",num2str(s)]).(allname) = de.TR.A.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLdy.TC.A.(["r",num2str(r),"_s",num2str(s)]).(allname) = dy.TC.A.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLdy.TDin.A.(["r",num2str(r),"_s",num2str(s)]).(allname) = dy.TDin.A.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLdy.TDout.A.(["r",num2str(r),"_s",num2str(s)]).(allname) = dy.TDout.A.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLdy.TR.A.(["r",num2str(r),"_s",num2str(s)]).(allname) = dy.TR.A.(["r",num2str(r),"_s",num2str(s)]).(runname);

					ALLdv.TC.F.(["r",num2str(r),"_s",num2str(s)]).(allname) = dv.TC.F.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLdv.TDin.F.(["r",num2str(r),"_s",num2str(s)]).(allname) = dv.TDin.F.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLdv.TDout.F.(["r",num2str(r),"_s",num2str(s)]).(allname) = dv.TDout.F.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLdv.TR.F.(["r",num2str(r),"_s",num2str(s)]).(allname) = dv.TR.F.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLde.TC.F.(["r",num2str(r),"_s",num2str(s)]).(allname) = de.TC.F.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLde.TDin.F.(["r",num2str(r),"_s",num2str(s)]).(allname) = de.TDin.F.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLde.TDout.F.(["r",num2str(r),"_s",num2str(s)]).(allname) = de.TDout.F.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLde.TR.F.(["r",num2str(r),"_s",num2str(s)]).(allname) = de.TR.F.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLdy.TC.F.(["r",num2str(r),"_s",num2str(s)]).(allname) = dy.TC.F.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLdy.TDin.F.(["r",num2str(r),"_s",num2str(s)]).(allname) = dy.TDin.F.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLdy.TDout.F.(["r",num2str(r),"_s",num2str(s)]).(allname) = dy.TDout.F.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLdy.TR.F.(["r",num2str(r),"_s",num2str(s)]).(allname) = dy.TR.F.(["r",num2str(r),"_s",num2str(s)]).(runname);

# MULTIPICATIVE decomposition

					ALLrv.TC.AF.(["r",num2str(r),"_s",num2str(s)]).(allname) = rv.TC.AF.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLrv.TDin.AF.(["r",num2str(r),"_s",num2str(s)]).(allname) = rv.TDin.AF.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLrv.TDout.AF.(["r",num2str(r),"_s",num2str(s)]).(allname) = rv.TDout.AF.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLrv.TR.AF.(["r",num2str(r),"_s",num2str(s)]).(allname) = rv.TR.AF.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLre.TC.AF.(["r",num2str(r),"_s",num2str(s)]).(allname) = re.TC.AF.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLre.TDin.AF.(["r",num2str(r),"_s",num2str(s)]).(allname) = re.TDin.AF.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLre.TDout.AF.(["r",num2str(r),"_s",num2str(s)]).(allname) = re.TDout.AF.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLre.TR.AF.(["r",num2str(r),"_s",num2str(s)]).(allname) = re.TR.AF.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLry.TC.AF.(["r",num2str(r),"_s",num2str(s)]).(allname) = ry.TC.AF.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLry.TDin.AF.(["r",num2str(r),"_s",num2str(s)]).(allname) = ry.TDin.AF.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLry.TDout.AF.(["r",num2str(r),"_s",num2str(s)]).(allname) = ry.TDout.AF.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLry.TR.AF.(["r",num2str(r),"_s",num2str(s)]).(allname) = ry.TR.AF.(["r",num2str(r),"_s",num2str(s)]).(runname);

					ALLrv.TC.A.(["r",num2str(r),"_s",num2str(s)]).(allname) = rv.TC.A.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLrv.TDin.A.(["r",num2str(r),"_s",num2str(s)]).(allname) = rv.TDin.A.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLrv.TDout.A.(["r",num2str(r),"_s",num2str(s)]).(allname) = rv.TDout.A.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLrv.TR.A.(["r",num2str(r),"_s",num2str(s)]).(allname) = rv.TR.A.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLre.TC.A.(["r",num2str(r),"_s",num2str(s)]).(allname) = re.TC.A.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLre.TDin.A.(["r",num2str(r),"_s",num2str(s)]).(allname) = re.TDin.A.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLre.TDout.A.(["r",num2str(r),"_s",num2str(s)]).(allname) = re.TDout.A.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLre.TR.A.(["r",num2str(r),"_s",num2str(s)]).(allname) = re.TR.A.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLry.TC.A.(["r",num2str(r),"_s",num2str(s)]).(allname) = ry.TC.A.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLry.TDin.A.(["r",num2str(r),"_s",num2str(s)]).(allname) = ry.TDin.A.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLry.TDout.A.(["r",num2str(r),"_s",num2str(s)]).(allname) = ry.TDout.A.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLry.TR.A.(["r",num2str(r),"_s",num2str(s)]).(allname) = ry.TR.A.(["r",num2str(r),"_s",num2str(s)]).(runname);

					ALLrv.TC.F.(["r",num2str(r),"_s",num2str(s)]).(allname) = rv.TC.F.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLrv.TDin.F.(["r",num2str(r),"_s",num2str(s)]).(allname) = rv.TDin.F.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLrv.TDout.F.(["r",num2str(r),"_s",num2str(s)]).(allname) = rv.TDout.F.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLrv.TR.F.(["r",num2str(r),"_s",num2str(s)]).(allname) = rv.TR.F.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLre.TC.F.(["r",num2str(r),"_s",num2str(s)]).(allname) = re.TC.F.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLre.TDin.F.(["r",num2str(r),"_s",num2str(s)]).(allname) = re.TDin.F.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLre.TDout.F.(["r",num2str(r),"_s",num2str(s)]).(allname) = re.TDout.F.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLre.TR.F.(["r",num2str(r),"_s",num2str(s)]).(allname) = re.TR.F.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLry.TC.F.(["r",num2str(r),"_s",num2str(s)]).(allname) = ry.TC.F.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLry.TDin.F.(["r",num2str(r),"_s",num2str(s)]).(allname) = ry.TDin.F.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLry.TDout.F.(["r",num2str(r),"_s",num2str(s)]).(allname) = ry.TDout.F.(["r",num2str(r),"_s",num2str(s)]).(runname);
					ALLry.TR.F.(["r",num2str(r),"_s",num2str(s)]).(allname) = ry.TR.F.(["r",num2str(r),"_s",num2str(s)]).(runname);

# end the if statement for (r != s)
				endif
# end loops for r and s
			endfor
		endfor
# end loop for the field identifier
	endfor
	clear dv* de* dy* rv* re* ry* filename B batch
# end loop for the batch identifier
endfor

# at this point, you must obtain ALL* structure arrays where the number of fields ALL**.T*.*.r**s**.*** in each structure array = number of file batched x number of Monte Carlo runs in each batch; default is 20 x 20 = 400
# each field ALL**.T*.*.r**s**.*** is a matrix or vector with the results of SDA of value added, emloyment or GDP
# explicitly define the number of fields in a structure array, for the use as the sample size later; use that F is now set to 20
NF = NB*F;

# print a message about the progress in the execution of the script (optional)
printf (["Now all data have been extracted and merged. " num2str(NF) " fields in each structure. Starting to compute averages, deviations and to run tests.\n"])

# define the name of the file that stores the results of the alternative, simplified estimation with the bi-proportinal allocation of market shares
filename = ["/[insert the path to the "KORUS_bp..." CSV files produced by the "KORUS_bp" script]/KORUS_bp_" y0 "-" y1 ".csv"];

# define the file names to save results later, one file per each type of variable (d = per cent deviation, ave = average, std = standard deviation, Ltest = Lilliefors test, SWtest = Shapiro-Wilk test)
filename_d = ["/[insert the path to the output CSV files]/KORUS_r(d)_" y0 "-" y1 ".csv"];
filename_ave = ["/[insert the path to the output CSV files]/KORUS_r(ave)_" y0 "-" y1 ".csv"];
filename_std = ["/[insert the path to the output CSV files]/KORUS_r(std)_" y0 "-" y1 ".csv"];
filename_Ltest = ["/[insert the path to the output CSV files]/KORUS_r(Ltest)_" y0 "-" y1 ".csv"];
filename_SWtest = ["/[insert the path to the output CSV files]/KORUS_r(SWtest)_" y0 "-" y1 ".csv"];

# write the first line in each file, so that the variables in loops are later appended to it
varname = ["KORUS_bp(d)_" y0 "-" y1];
dlmwrite (filename_d, varname, ",")
varname = ["KORUS_bp(ave)_" y0 "-" y1];
dlmwrite (filename_ave, varname, ",")
varname = ["KORUS_bp(std)_" y0 "-" y1];
dlmwrite (filename_std, varname, ",")
varname = ["KORUS_bp(Ltest)_" y0 "-" y1];
dlmwrite (filename_Ltest, varname, ",")
varname = ["KORUS_bp(SWtest)_" y0 "-" y1];
dlmwrite (filename_SWtest, varname, ",")

# start loop for country identifiers: r - partner (country of origin), s - importer/home (country in focus)
for s = [19,36]
	for r = [36,19]
# ignore a case where r = s
		if (r != s)
# apply TCD_struct function to compute the average and standard deviation for each structure array; the averages of the samples are referred to as the baseline estimates
# ADDITIVE

			[dv_TC_AF_ave, dv_TC_AF_std] = TCD_struct (ALLdv.TC.AF.(["r",num2str(r),"_s",num2str(s)]));
			[dv_TDin_AF_ave, dv_TDin_AF_std] = TCD_struct (ALLdv.TDin.AF.(["r",num2str(r),"_s",num2str(s)]));
			[dv_TDout_AF_ave, dv_TDout_AF_std] = TCD_struct (ALLdv.TDout.AF.(["r",num2str(r),"_s",num2str(s)]));
			[dv_TR_AF_ave, dv_TR_AF_std] = TCD_struct (ALLdv.TR.AF.(["r",num2str(r),"_s",num2str(s)]));
			[de_TC_AF_ave, de_TC_AF_std] = TCD_struct (ALLde.TC.AF.(["r",num2str(r),"_s",num2str(s)]));
			[de_TDin_AF_ave, de_TDin_AF_std] = TCD_struct (ALLde.TDin.AF.(["r",num2str(r),"_s",num2str(s)]));
			[de_TDout_AF_ave, de_TDout_AF_std] = TCD_struct (ALLde.TDout.AF.(["r",num2str(r),"_s",num2str(s)]));
			[de_TR_AF_ave, de_TR_AF_std] = TCD_struct (ALLde.TR.AF.(["r",num2str(r),"_s",num2str(s)]));
			[dy_TC_AF_ave, dy_TC_AF_std] = TCD_struct (ALLdy.TC.AF.(["r",num2str(r),"_s",num2str(s)]));
			[dy_TDin_AF_ave, dy_TDin_AF_std] = TCD_struct (ALLdy.TDin.AF.(["r",num2str(r),"_s",num2str(s)]));
			[dy_TDout_AF_ave, dy_TDout_AF_std] = TCD_struct (ALLdy.TDout.AF.(["r",num2str(r),"_s",num2str(s)]));
			[dy_TR_AF_ave, dy_TR_AF_std] = TCD_struct (ALLdy.TR.AF.(["r",num2str(r),"_s",num2str(s)]));

			[dv_TC_A_ave, dv_TC_A_std] = TCD_struct (ALLdv.TC.A.(["r",num2str(r),"_s",num2str(s)]));
			[dv_TDin_A_ave, dv_TDin_A_std] = TCD_struct (ALLdv.TDin.A.(["r",num2str(r),"_s",num2str(s)]));
			[dv_TDout_A_ave, dv_TDout_A_std] = TCD_struct (ALLdv.TDout.A.(["r",num2str(r),"_s",num2str(s)]));
			[dv_TR_A_ave, dv_TR_A_std] = TCD_struct (ALLdv.TR.A.(["r",num2str(r),"_s",num2str(s)]));
			[de_TC_A_ave, de_TC_A_std] = TCD_struct (ALLde.TC.A.(["r",num2str(r),"_s",num2str(s)]));
			[de_TDin_A_ave, de_TDin_A_std] = TCD_struct (ALLde.TDin.A.(["r",num2str(r),"_s",num2str(s)]));
			[de_TDout_A_ave, de_TDout_A_std] = TCD_struct (ALLde.TDout.A.(["r",num2str(r),"_s",num2str(s)]));
			[de_TR_A_ave, de_TR_A_std] = TCD_struct (ALLde.TR.A.(["r",num2str(r),"_s",num2str(s)]));
			[dy_TC_A_ave, dy_TC_A_std] = TCD_struct (ALLdy.TC.A.(["r",num2str(r),"_s",num2str(s)]));
			[dy_TDin_A_ave, dy_TDin_A_std] = TCD_struct (ALLdy.TDin.A.(["r",num2str(r),"_s",num2str(s)]));
			[dy_TDout_A_ave, dy_TDout_A_std] = TCD_struct (ALLdy.TDout.A.(["r",num2str(r),"_s",num2str(s)]));
			[dy_TR_A_ave, dy_TR_A_std] = TCD_struct (ALLdy.TR.A.(["r",num2str(r),"_s",num2str(s)]));

			[dv_TC_F_ave, dv_TC_F_std] = TCD_struct (ALLdv.TC.F.(["r",num2str(r),"_s",num2str(s)]));
			[dv_TDin_F_ave, dv_TDin_F_std] = TCD_struct (ALLdv.TDin.F.(["r",num2str(r),"_s",num2str(s)]));
			[dv_TDout_F_ave, dv_TDout_F_std] = TCD_struct (ALLdv.TDout.F.(["r",num2str(r),"_s",num2str(s)]));
			[dv_TR_F_ave, dv_TR_F_std] = TCD_struct (ALLdv.TR.F.(["r",num2str(r),"_s",num2str(s)]));
			[de_TC_F_ave, de_TC_F_std] = TCD_struct (ALLde.TC.F.(["r",num2str(r),"_s",num2str(s)]));
			[de_TDin_F_ave, de_TDin_F_std] = TCD_struct (ALLde.TDin.F.(["r",num2str(r),"_s",num2str(s)]));
			[de_TDout_F_ave, de_TDout_F_std] = TCD_struct (ALLde.TDout.F.(["r",num2str(r),"_s",num2str(s)]));
			[de_TR_F_ave, de_TR_F_std] = TCD_struct (ALLde.TR.F.(["r",num2str(r),"_s",num2str(s)]));
			[dy_TC_F_ave, dy_TC_F_std] = TCD_struct (ALLdy.TC.F.(["r",num2str(r),"_s",num2str(s)]));
			[dy_TDin_F_ave, dy_TDin_F_std] = TCD_struct (ALLdy.TDin.F.(["r",num2str(r),"_s",num2str(s)]));
			[dy_TDout_F_ave, dy_TDout_F_std] = TCD_struct (ALLdy.TDout.F.(["r",num2str(r),"_s",num2str(s)]));
			[dy_TR_F_ave, dy_TR_F_std] = TCD_struct (ALLdy.TR.F.(["r",num2str(r),"_s",num2str(s)]));

# MULTIPICATIVE
			[rv_TC_AF_ave, rv_TC_AF_std] = TCD_struct (ALLrv.TC.AF.(["r",num2str(r),"_s",num2str(s)]));
			[rv_TDin_AF_ave, rv_TDin_AF_std] = TCD_struct (ALLrv.TDin.AF.(["r",num2str(r),"_s",num2str(s)]));
			[rv_TDout_AF_ave, rv_TDout_AF_std] = TCD_struct (ALLrv.TDout.AF.(["r",num2str(r),"_s",num2str(s)]));
			[rv_TR_AF_ave, rv_TR_AF_std] = TCD_struct (ALLrv.TR.AF.(["r",num2str(r),"_s",num2str(s)]));
			[re_TC_AF_ave, re_TC_AF_std] = TCD_struct (ALLre.TC.AF.(["r",num2str(r),"_s",num2str(s)]));
			[re_TDin_AF_ave, re_TDin_AF_std] = TCD_struct (ALLre.TDin.AF.(["r",num2str(r),"_s",num2str(s)]));
			[re_TDout_AF_ave, re_TDout_AF_std] = TCD_struct (ALLre.TDout.AF.(["r",num2str(r),"_s",num2str(s)]));
			[re_TR_AF_ave, re_TR_AF_std] = TCD_struct (ALLre.TR.AF.(["r",num2str(r),"_s",num2str(s)]));
			[ry_TC_AF_ave, ry_TC_AF_std] = TCD_struct (ALLry.TC.AF.(["r",num2str(r),"_s",num2str(s)]));
			[ry_TDin_AF_ave, ry_TDin_AF_std] = TCD_struct (ALLry.TDin.AF.(["r",num2str(r),"_s",num2str(s)]));
			[ry_TDout_AF_ave, ry_TDout_AF_std] = TCD_struct (ALLry.TDout.AF.(["r",num2str(r),"_s",num2str(s)]));
			[ry_TR_AF_ave, ry_TR_AF_std] = TCD_struct (ALLry.TR.AF.(["r",num2str(r),"_s",num2str(s)]));

			[rv_TC_A_ave, rv_TC_A_std] = TCD_struct (ALLrv.TC.A.(["r",num2str(r),"_s",num2str(s)]));
			[rv_TDin_A_ave, rv_TDin_A_std] = TCD_struct (ALLrv.TDin.A.(["r",num2str(r),"_s",num2str(s)]));
			[rv_TDout_A_ave, rv_TDout_A_std] = TCD_struct (ALLrv.TDout.A.(["r",num2str(r),"_s",num2str(s)]));
			[rv_TR_A_ave, rv_TR_A_std] = TCD_struct (ALLrv.TR.A.(["r",num2str(r),"_s",num2str(s)]));
			[re_TC_A_ave, re_TC_A_std] = TCD_struct (ALLre.TC.A.(["r",num2str(r),"_s",num2str(s)]));
			[re_TDin_A_ave, re_TDin_A_std] = TCD_struct (ALLre.TDin.A.(["r",num2str(r),"_s",num2str(s)]));
			[re_TDout_A_ave, re_TDout_A_std] = TCD_struct (ALLre.TDout.A.(["r",num2str(r),"_s",num2str(s)]));
			[re_TR_A_ave, re_TR_A_std] = TCD_struct (ALLre.TR.A.(["r",num2str(r),"_s",num2str(s)]));
			[ry_TC_A_ave, ry_TC_A_std] = TCD_struct (ALLry.TC.A.(["r",num2str(r),"_s",num2str(s)]));
			[ry_TDin_A_ave, ry_TDin_A_std] = TCD_struct (ALLry.TDin.A.(["r",num2str(r),"_s",num2str(s)]));
			[ry_TDout_A_ave, ry_TDout_A_std] = TCD_struct (ALLry.TDout.A.(["r",num2str(r),"_s",num2str(s)]));
			[ry_TR_A_ave, ry_TR_A_std] = TCD_struct (ALLry.TR.A.(["r",num2str(r),"_s",num2str(s)]));

			[rv_TC_F_ave, rv_TC_F_std] = TCD_struct (ALLrv.TC.F.(["r",num2str(r),"_s",num2str(s)]));
			[rv_TDin_F_ave, rv_TDin_F_std] = TCD_struct (ALLrv.TDin.F.(["r",num2str(r),"_s",num2str(s)]));
			[rv_TDout_F_ave, rv_TDout_F_std] = TCD_struct (ALLrv.TDout.F.(["r",num2str(r),"_s",num2str(s)]));
			[rv_TR_F_ave, rv_TR_F_std] = TCD_struct (ALLrv.TR.F.(["r",num2str(r),"_s",num2str(s)]));
			[re_TC_F_ave, re_TC_F_std] = TCD_struct (ALLre.TC.F.(["r",num2str(r),"_s",num2str(s)]));
			[re_TDin_F_ave, re_TDin_F_std] = TCD_struct (ALLre.TDin.F.(["r",num2str(r),"_s",num2str(s)]));
			[re_TDout_F_ave, re_TDout_F_std] = TCD_struct (ALLre.TDout.F.(["r",num2str(r),"_s",num2str(s)]));
			[re_TR_F_ave, re_TR_F_std] = TCD_struct (ALLre.TR.F.(["r",num2str(r),"_s",num2str(s)]));
			[ry_TC_F_ave, ry_TC_F_std] = TCD_struct (ALLry.TC.F.(["r",num2str(r),"_s",num2str(s)]));
			[ry_TDin_F_ave, ry_TDin_F_std] = TCD_struct (ALLry.TDin.F.(["r",num2str(r),"_s",num2str(s)]));
			[ry_TDout_F_ave, ry_TDout_F_std] = TCD_struct (ALLry.TDout.F.(["r",num2str(r),"_s",num2str(s)]));
			[ry_TR_F_ave, ry_TR_F_std] = TCD_struct (ALLry.TR.F.(["r",num2str(r),"_s",num2str(s)]));

# read the alternative estimates based on a bi-proportinal allocation of market shares, from "KORUS_bp_y0-y1.csv" files
			if (and (s==19, r==36))
				dv_TC_AF_est = dlmread (filename, ",", [2, 0, 3, 35]);
				dv_TDin_AF_est = dlmread (filename, ",", [5, 0, 6, 35]);
				dv_TDout_AF_est = dlmread (filename, ",", [8, 0, 9, 35]);
				dv_TR_AF_est = dlmread (filename, ",", [11, 0, 12, 35]);
				de_TC_AF_est = dlmread (filename, ",", [14, 0, 15, 35]);
				de_TDin_AF_est = dlmread (filename, ",", [17, 0, 18, 35]);
				de_TDout_AF_est = dlmread (filename, ",", [20, 0, 21, 35]);
				de_TR_AF_est = dlmread (filename, ",", [23, 0, 24, 35]);
				dy_TC_AF_est = dlmread (filename, ",", [26, 0, 27, 0]);
				dy_TDin_AF_est = dlmread (filename, ",", [29, 0, 30, 0]);
				dy_TDout_AF_est = dlmread (filename, ",", [32, 0, 33, 0]);
				dy_TR_AF_est = dlmread (filename, ",", [35, 0, 36, 0]);
				rv_TC_AF_est = dlmread (filename, ",", [38, 0, 39, 35]);
				rv_TDin_AF_est = dlmread (filename, ",", [41, 0, 42, 35]);
				rv_TDout_AF_est = dlmread (filename, ",", [44, 0, 45, 35]);
				rv_TR_AF_est = dlmread (filename, ",", [47, 0, 48, 35]);
				re_TC_AF_est = dlmread (filename, ",", [50, 0, 51, 35]);
				re_TDin_AF_est = dlmread (filename, ",", [53, 0, 54, 35]);
				re_TDout_AF_est = dlmread (filename, ",", [56, 0, 57, 35]);
				re_TR_AF_est = dlmread (filename, ",", [59, 0, 60, 35]);
				ry_TC_AF_est = dlmread (filename, ",", [62, 0, 63, 0]);
				ry_TDin_AF_est = dlmread (filename, ",", [65, 0, 66, 0]);
				ry_TDout_AF_est = dlmread (filename, ",", [68, 0, 69, 0]);
				ry_TR_AF_est = dlmread (filename, ",", [71, 0, 72, 0]);
				dv_TC_A_est = dlmread (filename, ",", [74, 0, 75, 35]);
				dv_TDin_A_est = dlmread (filename, ",", [77, 0, 78, 35]);
				dv_TDout_A_est = dlmread (filename, ",", [80, 0, 81, 35]);
				dv_TR_A_est = dlmread (filename, ",", [83, 0, 84, 35]);
				de_TC_A_est = dlmread (filename, ",", [86, 0, 87, 35]);
				de_TDin_A_est = dlmread (filename, ",", [89, 0, 90, 35]);
				de_TDout_A_est = dlmread (filename, ",", [92, 0, 93, 35]);
				de_TR_A_est = dlmread (filename, ",", [95, 0, 96, 35]);
				dy_TC_A_est = dlmread (filename, ",", [98, 0, 99, 0]);
				dy_TDin_A_est = dlmread (filename, ",", [101, 0, 102, 0]);
				dy_TDout_A_est = dlmread (filename, ",", [104, 0, 105, 0]);
				dy_TR_A_est = dlmread (filename, ",", [107, 0, 108, 0]);
				rv_TC_A_est = dlmread (filename, ",", [110, 0, 111, 35]);
				rv_TDin_A_est = dlmread (filename, ",", [113, 0, 114, 35]);
				rv_TDout_A_est = dlmread (filename, ",", [116, 0, 117, 35]);
				rv_TR_A_est = dlmread (filename, ",", [119, 0, 120, 35]);
				re_TC_A_est = dlmread (filename, ",", [122, 0, 123, 35]);
				re_TDin_A_est = dlmread (filename, ",", [125, 0, 126, 35]);
				re_TDout_A_est = dlmread (filename, ",", [128, 0, 129, 35]);
				re_TR_A_est = dlmread (filename, ",", [131, 0, 132, 35]);
				ry_TC_A_est = dlmread (filename, ",", [134, 0, 135, 0]);
				ry_TDin_A_est = dlmread (filename, ",", [137, 0, 138, 0]);
				ry_TDout_A_est = dlmread (filename, ",", [140, 0, 141, 0]);
				ry_TR_A_est = dlmread (filename, ",", [143, 0, 144, 0]);
				dv_TC_F_est = dlmread (filename, ",", [146, 0, 147, 35]);
				dv_TDin_F_est = dlmread (filename, ",", [149, 0, 150, 35]);
				dv_TDout_F_est = dlmread (filename, ",", [152, 0, 153, 35]);
				dv_TR_F_est = dlmread (filename, ",", [155, 0, 156, 35]);
				de_TC_F_est = dlmread (filename, ",", [158, 0, 159, 35]);
				de_TDin_F_est = dlmread (filename, ",", [161, 0, 162, 35]);
				de_TDout_F_est = dlmread (filename, ",", [164, 0, 165, 35]);
				de_TR_F_est = dlmread (filename, ",", [167, 0, 168, 35]);
				dy_TC_F_est = dlmread (filename, ",", [170, 0, 171, 0]);
				dy_TDin_F_est = dlmread (filename, ",", [173, 0, 174, 0]);
				dy_TDout_F_est = dlmread (filename, ",", [176, 0, 177, 0]);
				dy_TR_F_est = dlmread (filename, ",", [179, 0, 180, 0]);
				rv_TC_F_est = dlmread (filename, ",", [182, 0, 183, 35]);
				rv_TDin_F_est = dlmread (filename, ",", [185, 0, 186, 35]);
				rv_TDout_F_est = dlmread (filename, ",", [188, 0, 189, 35]);
				rv_TR_F_est = dlmread (filename, ",", [191, 0, 192, 35]);
				re_TC_F_est = dlmread (filename, ",", [194, 0, 195, 35]);
				re_TDin_F_est = dlmread (filename, ",", [197, 0, 198, 35]);
				re_TDout_F_est = dlmread (filename, ",", [200, 0, 201, 35]);
				re_TR_F_est = dlmread (filename, ",", [203, 0, 204, 35]);
				ry_TC_F_est = dlmread (filename, ",", [206, 0, 207, 0]);
				ry_TDin_F_est = dlmread (filename, ",", [209, 0, 210, 0]);
				ry_TDout_F_est = dlmread (filename, ",", [212, 0, 213, 0]);
				ry_TR_F_est = dlmread (filename, ",", [215, 0, 216, 0]);
			elseif(and (s==36, r==19))
				dv_TC_AF_est = dlmread (filename, ",", [218, 0, 219, 35]);
				dv_TDin_AF_est = dlmread (filename, ",", [221, 0, 222, 35]);
				dv_TDout_AF_est = dlmread (filename, ",", [224, 0, 225, 35]);
				dv_TR_AF_est = dlmread (filename, ",", [227, 0, 228, 35]);
				de_TC_AF_est = dlmread (filename, ",", [230, 0, 231, 35]);
				de_TDin_AF_est = dlmread (filename, ",", [233, 0, 234, 35]);
				de_TDout_AF_est = dlmread (filename, ",", [236, 0, 237, 35]);
				de_TR_AF_est = dlmread (filename, ",", [239, 0, 240, 35]);
				dy_TC_AF_est = dlmread (filename, ",", [242, 0, 243, 0]);
				dy_TDin_AF_est = dlmread (filename, ",", [245, 0, 246, 0]);
				dy_TDout_AF_est = dlmread (filename, ",", [248, 0, 249, 0]);
				dy_TR_AF_est = dlmread (filename, ",", [251, 0, 252, 0]);
				rv_TC_AF_est = dlmread (filename, ",", [254, 0, 255, 35]);
				rv_TDin_AF_est = dlmread (filename, ",", [257, 0, 258, 35]);
				rv_TDout_AF_est = dlmread (filename, ",", [260, 0, 261, 35]);
				rv_TR_AF_est = dlmread (filename, ",", [263, 0, 264, 35]);
				re_TC_AF_est = dlmread (filename, ",", [266, 0, 267, 35]);
				re_TDin_AF_est = dlmread (filename, ",", [269, 0, 270, 35]);
				re_TDout_AF_est = dlmread (filename, ",", [272, 0, 273, 35]);
				re_TR_AF_est = dlmread (filename, ",", [275, 0, 276, 35]);
				ry_TC_AF_est = dlmread (filename, ",", [278, 0, 279, 0]);
				ry_TDin_AF_est = dlmread (filename, ",", [281, 0, 282, 0]);
				ry_TDout_AF_est = dlmread (filename, ",", [284, 0, 285, 0]);
				ry_TR_AF_est = dlmread (filename, ",", [287, 0, 288, 0]);
				dv_TC_A_est = dlmread (filename, ",", [290, 0, 291, 35]);
				dv_TDin_A_est = dlmread (filename, ",", [293, 0, 294, 35]);
				dv_TDout_A_est = dlmread (filename, ",", [296, 0, 297, 35]);
				dv_TR_A_est = dlmread (filename, ",", [299, 0, 300, 35]);
				de_TC_A_est = dlmread (filename, ",", [302, 0, 303, 35]);
				de_TDin_A_est = dlmread (filename, ",", [305, 0, 306, 35]);
				de_TDout_A_est = dlmread (filename, ",", [308, 0, 309, 35]);
				de_TR_A_est = dlmread (filename, ",", [311, 0, 312, 35]);
				dy_TC_A_est = dlmread (filename, ",", [314, 0, 315, 0]);
				dy_TDin_A_est = dlmread (filename, ",", [317, 0, 318, 0]);
				dy_TDout_A_est = dlmread (filename, ",", [320, 0, 321, 0]);
				dy_TR_A_est = dlmread (filename, ",", [323, 0, 324, 0]);
				rv_TC_A_est = dlmread (filename, ",", [326, 0, 327, 35]);
				rv_TDin_A_est = dlmread (filename, ",", [329, 0, 330, 35]);
				rv_TDout_A_est = dlmread (filename, ",", [332, 0, 333, 35]);
				rv_TR_A_est = dlmread (filename, ",", [335, 0, 336, 35]);
				re_TC_A_est = dlmread (filename, ",", [338, 0, 339, 35]);
				re_TDin_A_est = dlmread (filename, ",", [341, 0, 342, 35]);
				re_TDout_A_est = dlmread (filename, ",", [344, 0, 345, 35]);
				re_TR_A_est = dlmread (filename, ",", [347, 0, 348, 35]);
				ry_TC_A_est = dlmread (filename, ",", [350, 0, 351, 0]);
				ry_TDin_A_est = dlmread (filename, ",", [353, 0, 354, 0]);
				ry_TDout_A_est = dlmread (filename, ",", [356, 0, 357, 0]);
				ry_TR_A_est = dlmread (filename, ",", [359, 0, 360, 0]);
				dv_TC_F_est = dlmread (filename, ",", [362, 0, 363, 35]);
				dv_TDin_F_est = dlmread (filename, ",", [365, 0, 366, 35]);
				dv_TDout_F_est = dlmread (filename, ",", [368, 0, 369, 35]);
				dv_TR_F_est = dlmread (filename, ",", [371, 0, 372, 35]);
				de_TC_F_est = dlmread (filename, ",", [374, 0, 375, 35]);
				de_TDin_F_est = dlmread (filename, ",", [377, 0, 378, 35]);
				de_TDout_F_est = dlmread (filename, ",", [380, 0, 381, 35]);
				de_TR_F_est = dlmread (filename, ",", [383, 0, 384, 35]);
				dy_TC_F_est = dlmread (filename, ",", [386, 0, 387, 0]);
				dy_TDin_F_est = dlmread (filename, ",", [389, 0, 390, 0]);
				dy_TDout_F_est = dlmread (filename, ",", [392, 0, 393, 0]);
				dy_TR_F_est = dlmread (filename, ",", [395, 0, 396, 0]);
				rv_TC_F_est = dlmread (filename, ",", [398, 0, 399, 35]);
				rv_TDin_F_est = dlmread (filename, ",", [401, 0, 402, 35]);
				rv_TDout_F_est = dlmread (filename, ",", [404, 0, 405, 35]);
				rv_TR_F_est = dlmread (filename, ",", [407, 0, 408, 35]);
				re_TC_F_est = dlmread (filename, ",", [410, 0, 411, 35]);
				re_TDin_F_est = dlmread (filename, ",", [413, 0, 414, 35]);
				re_TDout_F_est = dlmread (filename, ",", [416, 0, 417, 35]);
				re_TR_F_est = dlmread (filename, ",", [419, 0, 420, 35]);
				ry_TC_F_est = dlmread (filename, ",", [422, 0, 423, 0]);
				ry_TDin_F_est = dlmread (filename, ",", [425, 0, 426, 0]);
				ry_TDout_F_est = dlmread (filename, ",", [428, 0, 429, 0]);
				ry_TR_F_est = dlmread (filename, ",", [431, 0, 432, 0]);
			endif

# compute the deviation of the alternative estimates from the baseline estimates
			dv_TC_AF_d = dv_TC_AF_est./dv_TC_AF_ave - 1;
			dv_TDin_AF_d = dv_TDin_AF_est./dv_TDin_AF_ave - 1;
			dv_TDout_AF_d = dv_TDout_AF_est./dv_TDout_AF_ave - 1;
			dv_TR_AF_d = dv_TR_AF_est./dv_TR_AF_ave - 1;
			de_TC_AF_d = de_TC_AF_est./de_TC_AF_ave - 1;
			de_TDin_AF_d = de_TDin_AF_est./de_TDin_AF_ave - 1;
			de_TDout_AF_d = de_TDout_AF_est./de_TDout_AF_ave - 1;
			de_TR_AF_d = de_TR_AF_est./de_TR_AF_ave - 1;
			dy_TC_AF_d = dy_TC_AF_est./dy_TC_AF_ave - 1;
			dy_TDin_AF_d = dy_TDin_AF_est./dy_TDin_AF_ave - 1;
			dy_TDout_AF_d = dy_TDout_AF_est./dy_TDout_AF_ave - 1;
			dy_TR_AF_d = dy_TR_AF_est./dy_TR_AF_ave - 1;
			rv_TC_AF_d = rv_TC_AF_est./rv_TC_AF_ave - 1;
			rv_TDin_AF_d = rv_TDin_AF_est./rv_TDin_AF_ave - 1;
			rv_TDout_AF_d = rv_TDout_AF_est./rv_TDout_AF_ave - 1;
			rv_TR_AF_d = rv_TR_AF_est./rv_TR_AF_ave - 1;
			re_TC_AF_d = re_TC_AF_est./re_TC_AF_ave - 1;
			re_TDin_AF_d = re_TDin_AF_est./re_TDin_AF_ave - 1;
			re_TDout_AF_d = re_TDout_AF_est./re_TDout_AF_ave - 1;
			re_TR_AF_d = re_TR_AF_est./re_TR_AF_ave - 1;
			ry_TC_AF_d = ry_TC_AF_est./ry_TC_AF_ave - 1;
			ry_TDin_AF_d = ry_TDin_AF_est./ry_TDin_AF_ave - 1;
			ry_TDout_AF_d = ry_TDout_AF_est./ry_TDout_AF_ave - 1;
			ry_TR_AF_d = ry_TR_AF_est./ry_TR_AF_ave - 1;

			dv_TC_A_d = dv_TC_A_est./dv_TC_A_ave - 1;
			dv_TDin_A_d = dv_TDin_A_est./dv_TDin_A_ave - 1;
			dv_TDout_A_d = dv_TDout_A_est./dv_TDout_A_ave - 1;
			dv_TR_A_d = dv_TR_A_est./dv_TR_A_ave - 1;
			de_TC_A_d = de_TC_A_est./de_TC_A_ave - 1;
			de_TDin_A_d = de_TDin_A_est./de_TDin_A_ave - 1;
			de_TDout_A_d = de_TDout_A_est./de_TDout_A_ave - 1;
			de_TR_A_d = de_TR_A_est./de_TR_A_ave - 1;
			dy_TC_A_d = dy_TC_A_est./dy_TC_A_ave - 1;
			dy_TDin_A_d = dy_TDin_A_est./dy_TDin_A_ave - 1;
			dy_TDout_A_d = dy_TDout_A_est./dy_TDout_A_ave - 1;
			dy_TR_A_d = dy_TR_A_est./dy_TR_A_ave - 1;
			rv_TC_A_d = rv_TC_A_est./rv_TC_A_ave - 1;
			rv_TDin_A_d = rv_TDin_A_est./rv_TDin_A_ave - 1;
			rv_TDout_A_d = rv_TDout_A_est./rv_TDout_A_ave - 1;
			rv_TR_A_d = rv_TR_A_est./rv_TR_A_ave - 1;
			re_TC_A_d = re_TC_A_est./re_TC_A_ave - 1;
			re_TDin_A_d = re_TDin_A_est./re_TDin_A_ave - 1;
			re_TDout_A_d = re_TDout_A_est./re_TDout_A_ave - 1;
			re_TR_A_d = re_TR_A_est./re_TR_A_ave - 1;
			ry_TC_A_d = ry_TC_A_est./ry_TC_A_ave - 1;
			ry_TDin_A_d = ry_TDin_A_est./ry_TDin_A_ave - 1;
			ry_TDout_A_d = ry_TDout_A_est./ry_TDout_A_ave - 1;
			ry_TR_A_d = ry_TR_A_est./ry_TR_A_ave - 1;

			dv_TC_F_d = dv_TC_F_est./dv_TC_F_ave - 1;
			dv_TDin_F_d = dv_TDin_F_est./dv_TDin_F_ave - 1;
			dv_TDout_F_d = dv_TDout_F_est./dv_TDout_F_ave - 1;
			dv_TR_F_d = dv_TR_F_est./dv_TR_F_ave - 1;
			de_TC_F_d = de_TC_F_est./de_TC_F_ave - 1;
			de_TDin_F_d = de_TDin_F_est./de_TDin_F_ave - 1;
			de_TDout_F_d = de_TDout_F_est./de_TDout_F_ave - 1;
			de_TR_F_d = de_TR_F_est./de_TR_F_ave - 1;
			dy_TC_F_d = dy_TC_F_est./dy_TC_F_ave - 1;
			dy_TDin_F_d = dy_TDin_F_est./dy_TDin_F_ave - 1;
			dy_TDout_F_d = dy_TDout_F_est./dy_TDout_F_ave - 1;
			dy_TR_F_d = dy_TR_F_est./dy_TR_F_ave - 1;
			rv_TC_F_d = rv_TC_F_est./rv_TC_F_ave - 1;
			rv_TDin_F_d = rv_TDin_F_est./rv_TDin_F_ave - 1;
			rv_TDout_F_d = rv_TDout_F_est./rv_TDout_F_ave - 1;
			rv_TR_F_d = rv_TR_F_est./rv_TR_F_ave - 1;
			re_TC_F_d = re_TC_F_est./re_TC_F_ave - 1;
			re_TDin_F_d = re_TDin_F_est./re_TDin_F_ave - 1;
			re_TDout_F_d = re_TDout_F_est./re_TDout_F_ave - 1;
			re_TR_F_d = re_TR_F_est./re_TR_F_ave - 1;
			ry_TC_F_d = ry_TC_F_est./ry_TC_F_ave - 1;
			ry_TDin_F_d = ry_TDin_F_est./ry_TDin_F_ave - 1;
			ry_TDout_F_d = ry_TDout_F_est./ry_TDout_F_ave - 1;
			ry_TR_F_d = ry_TR_F_est./ry_TR_F_ave - 1;

# test the null hypothesis that the results are normally distributed
# use the Lilliefors test function for structure arrays
# ADDITIVE
			dv_TC_AF_Ltest = struct_Ltest (ALLdv.TC.AF.(["r",num2str(r),"_s",num2str(s)]));
			dv_TDin_AF_Ltest = struct_Ltest (ALLdv.TDin.AF.(["r",num2str(r),"_s",num2str(s)]));
			dv_TDout_AF_Ltest = struct_Ltest (ALLdv.TDout.AF.(["r",num2str(r),"_s",num2str(s)]));
			dv_TR_AF_Ltest = struct_Ltest (ALLdv.TR.AF.(["r",num2str(r),"_s",num2str(s)]));
			de_TC_AF_Ltest = struct_Ltest (ALLde.TC.AF.(["r",num2str(r),"_s",num2str(s)]));
			de_TDin_AF_Ltest = struct_Ltest (ALLde.TDin.AF.(["r",num2str(r),"_s",num2str(s)]));
			de_TDout_AF_Ltest = struct_Ltest (ALLde.TDout.AF.(["r",num2str(r),"_s",num2str(s)]));
			de_TR_AF_Ltest = struct_Ltest (ALLde.TR.AF.(["r",num2str(r),"_s",num2str(s)]));
			dy_TC_AF_Ltest = struct_Ltest (ALLdy.TC.AF.(["r",num2str(r),"_s",num2str(s)]));
			dy_TDin_AF_Ltest = struct_Ltest (ALLdy.TDin.AF.(["r",num2str(r),"_s",num2str(s)]));
			dy_TDout_AF_Ltest = struct_Ltest (ALLdy.TDout.AF.(["r",num2str(r),"_s",num2str(s)]));
			dy_TR_AF_Ltest = struct_Ltest (ALLdy.TR.AF.(["r",num2str(r),"_s",num2str(s)]));

			dv_TC_A_Ltest = struct_Ltest (ALLdv.TC.A.(["r",num2str(r),"_s",num2str(s)]));
			dv_TDin_A_Ltest = struct_Ltest (ALLdv.TDin.A.(["r",num2str(r),"_s",num2str(s)]));
			dv_TDout_A_Ltest = struct_Ltest (ALLdv.TDout.A.(["r",num2str(r),"_s",num2str(s)]));
			dv_TR_A_Ltest = struct_Ltest (ALLdv.TR.A.(["r",num2str(r),"_s",num2str(s)]));
			de_TC_A_Ltest = struct_Ltest (ALLde.TC.A.(["r",num2str(r),"_s",num2str(s)]));
			de_TDin_A_Ltest = struct_Ltest (ALLde.TDin.A.(["r",num2str(r),"_s",num2str(s)]));
			de_TDout_A_Ltest = struct_Ltest (ALLde.TDout.A.(["r",num2str(r),"_s",num2str(s)]));
			de_TR_A_Ltest = struct_Ltest (ALLde.TR.A.(["r",num2str(r),"_s",num2str(s)]));
			dy_TC_A_Ltest = struct_Ltest (ALLdy.TC.A.(["r",num2str(r),"_s",num2str(s)]));
			dy_TDin_A_Ltest = struct_Ltest (ALLdy.TDin.A.(["r",num2str(r),"_s",num2str(s)]));
			dy_TDout_A_Ltest = struct_Ltest (ALLdy.TDout.A.(["r",num2str(r),"_s",num2str(s)]));
			dy_TR_A_Ltest = struct_Ltest (ALLdy.TR.A.(["r",num2str(r),"_s",num2str(s)]));

			dv_TC_F_Ltest = struct_Ltest (ALLdv.TC.F.(["r",num2str(r),"_s",num2str(s)]));
			dv_TDin_F_Ltest = struct_Ltest (ALLdv.TDin.F.(["r",num2str(r),"_s",num2str(s)]));
			dv_TDout_F_Ltest = struct_Ltest (ALLdv.TDout.F.(["r",num2str(r),"_s",num2str(s)]));
			dv_TR_F_Ltest = struct_Ltest (ALLdv.TR.F.(["r",num2str(r),"_s",num2str(s)]));
			de_TC_F_Ltest = struct_Ltest (ALLde.TC.F.(["r",num2str(r),"_s",num2str(s)]));
			de_TDin_F_Ltest = struct_Ltest (ALLde.TDin.F.(["r",num2str(r),"_s",num2str(s)]));
			de_TDout_F_Ltest = struct_Ltest (ALLde.TDout.F.(["r",num2str(r),"_s",num2str(s)]));
			de_TR_F_Ltest = struct_Ltest (ALLde.TR.F.(["r",num2str(r),"_s",num2str(s)]));
			dy_TC_F_Ltest = struct_Ltest (ALLdy.TC.F.(["r",num2str(r),"_s",num2str(s)]));
			dy_TDin_F_Ltest = struct_Ltest (ALLdy.TDin.F.(["r",num2str(r),"_s",num2str(s)]));
			dy_TDout_F_Ltest = struct_Ltest (ALLdy.TDout.F.(["r",num2str(r),"_s",num2str(s)]));
			dy_TR_F_Ltest = struct_Ltest (ALLdy.TR.F.(["r",num2str(r),"_s",num2str(s)]));

# MULTIPICATIVE
			rv_TC_AF_Ltest = struct_Ltest (ALLrv.TC.AF.(["r",num2str(r),"_s",num2str(s)]));
			rv_TDin_AF_Ltest = struct_Ltest (ALLrv.TDin.AF.(["r",num2str(r),"_s",num2str(s)]));
			rv_TDout_AF_Ltest = struct_Ltest (ALLrv.TDout.AF.(["r",num2str(r),"_s",num2str(s)]));
			rv_TR_AF_Ltest = struct_Ltest (ALLrv.TR.AF.(["r",num2str(r),"_s",num2str(s)]));
			re_TC_AF_Ltest = struct_Ltest (ALLre.TC.AF.(["r",num2str(r),"_s",num2str(s)]));
			re_TDin_AF_Ltest = struct_Ltest (ALLre.TDin.AF.(["r",num2str(r),"_s",num2str(s)]));
			re_TDout_AF_Ltest = struct_Ltest (ALLre.TDout.AF.(["r",num2str(r),"_s",num2str(s)]));
			re_TR_AF_Ltest = struct_Ltest (ALLre.TR.AF.(["r",num2str(r),"_s",num2str(s)]));
			ry_TC_AF_Ltest = struct_Ltest (ALLry.TC.AF.(["r",num2str(r),"_s",num2str(s)]));
			ry_TDin_AF_Ltest = struct_Ltest (ALLry.TDin.AF.(["r",num2str(r),"_s",num2str(s)]));
			ry_TDout_AF_Ltest = struct_Ltest (ALLry.TDout.AF.(["r",num2str(r),"_s",num2str(s)]));
			ry_TR_AF_Ltest = struct_Ltest (ALLry.TR.AF.(["r",num2str(r),"_s",num2str(s)]));

			rv_TC_A_Ltest = struct_Ltest (ALLrv.TC.A.(["r",num2str(r),"_s",num2str(s)]));
			rv_TDin_A_Ltest = struct_Ltest (ALLrv.TDin.A.(["r",num2str(r),"_s",num2str(s)]));
			rv_TDout_A_Ltest = struct_Ltest (ALLrv.TDout.A.(["r",num2str(r),"_s",num2str(s)]));
			rv_TR_A_Ltest = struct_Ltest (ALLrv.TR.A.(["r",num2str(r),"_s",num2str(s)]));
			re_TC_A_Ltest = struct_Ltest (ALLre.TC.A.(["r",num2str(r),"_s",num2str(s)]));
			re_TDin_A_Ltest = struct_Ltest (ALLre.TDin.A.(["r",num2str(r),"_s",num2str(s)]));
			re_TDout_A_Ltest = struct_Ltest (ALLre.TDout.A.(["r",num2str(r),"_s",num2str(s)]));
			re_TR_A_Ltest = struct_Ltest (ALLre.TR.A.(["r",num2str(r),"_s",num2str(s)]));
			ry_TC_A_Ltest = struct_Ltest (ALLry.TC.A.(["r",num2str(r),"_s",num2str(s)]));
			ry_TDin_A_Ltest = struct_Ltest (ALLry.TDin.A.(["r",num2str(r),"_s",num2str(s)]));
			ry_TDout_A_Ltest = struct_Ltest (ALLry.TDout.A.(["r",num2str(r),"_s",num2str(s)]));
			ry_TR_A_Ltest = struct_Ltest (ALLry.TR.A.(["r",num2str(r),"_s",num2str(s)]));

			rv_TC_F_Ltest = struct_Ltest (ALLrv.TC.F.(["r",num2str(r),"_s",num2str(s)]));
			rv_TDin_F_Ltest = struct_Ltest (ALLrv.TDin.F.(["r",num2str(r),"_s",num2str(s)]));
			rv_TDout_F_Ltest = struct_Ltest (ALLrv.TDout.F.(["r",num2str(r),"_s",num2str(s)]));
			rv_TR_F_Ltest = struct_Ltest (ALLrv.TR.F.(["r",num2str(r),"_s",num2str(s)]));
			re_TC_F_Ltest = struct_Ltest (ALLre.TC.F.(["r",num2str(r),"_s",num2str(s)]));
			re_TDin_F_Ltest = struct_Ltest (ALLre.TDin.F.(["r",num2str(r),"_s",num2str(s)]));
			re_TDout_F_Ltest = struct_Ltest (ALLre.TDout.F.(["r",num2str(r),"_s",num2str(s)]));
			re_TR_F_Ltest = struct_Ltest (ALLre.TR.F.(["r",num2str(r),"_s",num2str(s)]));
			ry_TC_F_Ltest = struct_Ltest (ALLry.TC.F.(["r",num2str(r),"_s",num2str(s)]));
			ry_TDin_F_Ltest = struct_Ltest (ALLry.TDin.F.(["r",num2str(r),"_s",num2str(s)]));
			ry_TDout_F_Ltest = struct_Ltest (ALLry.TDout.F.(["r",num2str(r),"_s",num2str(s)]));
			ry_TR_F_Ltest = struct_Ltest (ALLry.TR.F.(["r",num2str(r),"_s",num2str(s)]));

# use the Shapiro-Wilk test function for structure arrays
# ADDITIVE
			dv_TC_AF_SWtest = struct_SWtest (ALLdv.TC.AF.(["r",num2str(r),"_s",num2str(s)]));
			dv_TDin_AF_SWtest = struct_SWtest (ALLdv.TDin.AF.(["r",num2str(r),"_s",num2str(s)]));
			dv_TDout_AF_SWtest = struct_SWtest (ALLdv.TDout.AF.(["r",num2str(r),"_s",num2str(s)]));
			dv_TR_AF_SWtest = struct_SWtest (ALLdv.TR.AF.(["r",num2str(r),"_s",num2str(s)]));
			de_TC_AF_SWtest = struct_SWtest (ALLde.TC.AF.(["r",num2str(r),"_s",num2str(s)]));
			de_TDin_AF_SWtest = struct_SWtest (ALLde.TDin.AF.(["r",num2str(r),"_s",num2str(s)]));
			de_TDout_AF_SWtest = struct_SWtest (ALLde.TDout.AF.(["r",num2str(r),"_s",num2str(s)]));
			de_TR_AF_SWtest = struct_SWtest (ALLde.TR.AF.(["r",num2str(r),"_s",num2str(s)]));
			dy_TC_AF_SWtest = struct_SWtest (ALLdy.TC.AF.(["r",num2str(r),"_s",num2str(s)]));
			dy_TDin_AF_SWtest = struct_SWtest (ALLdy.TDin.AF.(["r",num2str(r),"_s",num2str(s)]));
			dy_TDout_AF_SWtest = struct_SWtest (ALLdy.TDout.AF.(["r",num2str(r),"_s",num2str(s)]));
			dy_TR_AF_SWtest = struct_SWtest (ALLdy.TR.AF.(["r",num2str(r),"_s",num2str(s)]));

			dv_TC_A_SWtest = struct_SWtest (ALLdv.TC.A.(["r",num2str(r),"_s",num2str(s)]));
			dv_TDin_A_SWtest = struct_SWtest (ALLdv.TDin.A.(["r",num2str(r),"_s",num2str(s)]));
			dv_TDout_A_SWtest = struct_SWtest (ALLdv.TDout.A.(["r",num2str(r),"_s",num2str(s)]));
			dv_TR_A_SWtest = struct_SWtest (ALLdv.TR.A.(["r",num2str(r),"_s",num2str(s)]));
			de_TC_A_SWtest = struct_SWtest (ALLde.TC.A.(["r",num2str(r),"_s",num2str(s)]));
			de_TDin_A_SWtest = struct_SWtest (ALLde.TDin.A.(["r",num2str(r),"_s",num2str(s)]));
			de_TDout_A_SWtest = struct_SWtest (ALLde.TDout.A.(["r",num2str(r),"_s",num2str(s)]));
			de_TR_A_SWtest = struct_SWtest (ALLde.TR.A.(["r",num2str(r),"_s",num2str(s)]));
			dy_TC_A_SWtest = struct_SWtest (ALLdy.TC.A.(["r",num2str(r),"_s",num2str(s)]));
			dy_TDin_A_SWtest = struct_SWtest (ALLdy.TDin.A.(["r",num2str(r),"_s",num2str(s)]));
			dy_TDout_A_SWtest = struct_SWtest (ALLdy.TDout.A.(["r",num2str(r),"_s",num2str(s)]));
			dy_TR_A_SWtest = struct_SWtest (ALLdy.TR.A.(["r",num2str(r),"_s",num2str(s)]));

			dv_TC_F_SWtest = struct_SWtest (ALLdv.TC.F.(["r",num2str(r),"_s",num2str(s)]));
			dv_TDin_F_SWtest = struct_SWtest (ALLdv.TDin.F.(["r",num2str(r),"_s",num2str(s)]));
			dv_TDout_F_SWtest = struct_SWtest (ALLdv.TDout.F.(["r",num2str(r),"_s",num2str(s)]));
			dv_TR_F_SWtest = struct_SWtest (ALLdv.TR.F.(["r",num2str(r),"_s",num2str(s)]));
			de_TC_F_SWtest = struct_SWtest (ALLde.TC.F.(["r",num2str(r),"_s",num2str(s)]));
			de_TDin_F_SWtest = struct_SWtest (ALLde.TDin.F.(["r",num2str(r),"_s",num2str(s)]));
			de_TDout_F_SWtest = struct_SWtest (ALLde.TDout.F.(["r",num2str(r),"_s",num2str(s)]));
			de_TR_F_SWtest = struct_SWtest (ALLde.TR.F.(["r",num2str(r),"_s",num2str(s)]));
			dy_TC_F_SWtest = struct_SWtest (ALLdy.TC.F.(["r",num2str(r),"_s",num2str(s)]));
			dy_TDin_F_SWtest = struct_SWtest (ALLdy.TDin.F.(["r",num2str(r),"_s",num2str(s)]));
			dy_TDout_F_SWtest = struct_SWtest (ALLdy.TDout.F.(["r",num2str(r),"_s",num2str(s)]));
			dy_TR_F_SWtest = struct_SWtest (ALLdy.TR.F.(["r",num2str(r),"_s",num2str(s)]));

# MULTIPICATIVE
			rv_TC_AF_SWtest = struct_SWtest (ALLrv.TC.AF.(["r",num2str(r),"_s",num2str(s)]));
			rv_TDin_AF_SWtest = struct_SWtest (ALLrv.TDin.AF.(["r",num2str(r),"_s",num2str(s)]));
			rv_TDout_AF_SWtest = struct_SWtest (ALLrv.TDout.AF.(["r",num2str(r),"_s",num2str(s)]));
			rv_TR_AF_SWtest = struct_SWtest (ALLrv.TR.AF.(["r",num2str(r),"_s",num2str(s)]));
			re_TC_AF_SWtest = struct_SWtest (ALLre.TC.AF.(["r",num2str(r),"_s",num2str(s)]));
			re_TDin_AF_SWtest = struct_SWtest (ALLre.TDin.AF.(["r",num2str(r),"_s",num2str(s)]));
			re_TDout_AF_SWtest = struct_SWtest (ALLre.TDout.AF.(["r",num2str(r),"_s",num2str(s)]));
			re_TR_AF_SWtest = struct_SWtest (ALLre.TR.AF.(["r",num2str(r),"_s",num2str(s)]));
			ry_TC_AF_SWtest = struct_SWtest (ALLry.TC.AF.(["r",num2str(r),"_s",num2str(s)]));
			ry_TDin_AF_SWtest = struct_SWtest (ALLry.TDin.AF.(["r",num2str(r),"_s",num2str(s)]));
			ry_TDout_AF_SWtest = struct_SWtest (ALLry.TDout.AF.(["r",num2str(r),"_s",num2str(s)]));
			ry_TR_AF_SWtest = struct_SWtest (ALLry.TR.AF.(["r",num2str(r),"_s",num2str(s)]));

			rv_TC_A_SWtest = struct_SWtest (ALLrv.TC.A.(["r",num2str(r),"_s",num2str(s)]));
			rv_TDin_A_SWtest = struct_SWtest (ALLrv.TDin.A.(["r",num2str(r),"_s",num2str(s)]));
			rv_TDout_A_SWtest = struct_SWtest (ALLrv.TDout.A.(["r",num2str(r),"_s",num2str(s)]));
			rv_TR_A_SWtest = struct_SWtest (ALLrv.TR.A.(["r",num2str(r),"_s",num2str(s)]));
			re_TC_A_SWtest = struct_SWtest (ALLre.TC.A.(["r",num2str(r),"_s",num2str(s)]));
			re_TDin_A_SWtest = struct_SWtest (ALLre.TDin.A.(["r",num2str(r),"_s",num2str(s)]));
			re_TDout_A_SWtest = struct_SWtest (ALLre.TDout.A.(["r",num2str(r),"_s",num2str(s)]));
			re_TR_A_SWtest = struct_SWtest (ALLre.TR.A.(["r",num2str(r),"_s",num2str(s)]));
			ry_TC_A_SWtest = struct_SWtest (ALLry.TC.A.(["r",num2str(r),"_s",num2str(s)]));
			ry_TDin_A_SWtest = struct_SWtest (ALLry.TDin.A.(["r",num2str(r),"_s",num2str(s)]));
			ry_TDout_A_SWtest = struct_SWtest (ALLry.TDout.A.(["r",num2str(r),"_s",num2str(s)]));
			ry_TR_A_SWtest = struct_SWtest (ALLry.TR.A.(["r",num2str(r),"_s",num2str(s)]));

			rv_TC_F_SWtest = struct_SWtest (ALLrv.TC.F.(["r",num2str(r),"_s",num2str(s)]));
			rv_TDin_F_SWtest = struct_SWtest (ALLrv.TDin.F.(["r",num2str(r),"_s",num2str(s)]));
			rv_TDout_F_SWtest = struct_SWtest (ALLrv.TDout.F.(["r",num2str(r),"_s",num2str(s)]));
			rv_TR_F_SWtest = struct_SWtest (ALLrv.TR.F.(["r",num2str(r),"_s",num2str(s)]));
			re_TC_F_SWtest = struct_SWtest (ALLre.TC.F.(["r",num2str(r),"_s",num2str(s)]));
			re_TDin_F_SWtest = struct_SWtest (ALLre.TDin.F.(["r",num2str(r),"_s",num2str(s)]));
			re_TDout_F_SWtest = struct_SWtest (ALLre.TDout.F.(["r",num2str(r),"_s",num2str(s)]));
			re_TR_F_SWtest = struct_SWtest (ALLre.TR.F.(["r",num2str(r),"_s",num2str(s)]));
			ry_TC_F_SWtest = struct_SWtest (ALLry.TC.F.(["r",num2str(r),"_s",num2str(s)]));
			ry_TDin_F_SWtest = struct_SWtest (ALLry.TDin.F.(["r",num2str(r),"_s",num2str(s)]));
			ry_TDout_F_SWtest = struct_SWtest (ALLry.TDout.F.(["r",num2str(r),"_s",num2str(s)]));
			ry_TR_F_SWtest = struct_SWtest (ALLry.TR.F.(["r",num2str(r),"_s",num2str(s)]));


# write data in the pre-defined CSV files

# file with [per cent] deviations
			varname = ["dvTCAFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, dv_TC_AF_d, ",", "-append")
			varname = ["dvTDinAFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, dv_TDin_AF_d, ",", "-append")
			varname = ["dvTDoutAFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, dv_TDout_AF_d, ",", "-append")
			varname = ["dvTRAFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, dv_TR_AF_d, ",", "-append")
			varname = ["deTCAFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, de_TC_AF_d, ",", "-append")
			varname = ["deTDinAFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, de_TDin_AF_d, ",", "-append")
			varname = ["deTDoutAFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, de_TDout_AF_d, ",", "-append")
			varname = ["deTRAFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, de_TR_AF_d, ",", "-append")
			varname = ["dyTCAFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, dy_TC_AF_d, ",", "-append")
			varname = ["dyTDinAFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, dy_TDin_AF_d, ",", "-append")
			varname = ["dyTDoutAFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, dy_TDout_AF_d, ",", "-append")
			varname = ["dyTRAFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, dy_TR_AF_d, ",", "-append")

			varname = ["rvTCAFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, rv_TC_AF_d, ",", "-append")
			varname = ["rvTDinAFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, rv_TDin_AF_d, ",", "-append")
			varname = ["rvTDoutAFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, rv_TDout_AF_d, ",", "-append")
			varname = ["rvTRAFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, rv_TR_AF_d, ",", "-append")
			varname = ["reTCAFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, re_TC_AF_d, ",", "-append")
			varname = ["reTDinAFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, re_TDin_AF_d, ",", "-append")
			varname = ["reTDoutAFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, re_TDout_AF_d, ",", "-append")
			varname = ["reTRAFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, re_TR_AF_d, ",", "-append")
			varname = ["ryTCAFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, ry_TC_AF_d, ",", "-append")
			varname = ["ryTDinAFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, ry_TDin_AF_d, ",", "-append")
			varname = ["ryTDoutAFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, ry_TDout_AF_d, ",", "-append")
			varname = ["ryTRAFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, ry_TR_AF_d, ",", "-append")

			varname = ["dvTCAd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, dv_TC_A_d, ",", "-append")
			varname = ["dvTDinAd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, dv_TDin_A_d, ",", "-append")
			varname = ["dvTDoutAd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, dv_TDout_A_d, ",", "-append")
			varname = ["dvTRAd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, dv_TR_A_d, ",", "-append")
			varname = ["deTCAd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, de_TC_A_d, ",", "-append")
			varname = ["deTDinAd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, de_TDin_A_d, ",", "-append")
			varname = ["deTDoutAd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, de_TDout_A_d, ",", "-append")
			varname = ["deTRAd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, de_TR_A_d, ",", "-append")
			varname = ["dyTCAd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, dy_TC_A_d, ",", "-append")
			varname = ["dyTDinAd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, dy_TDin_A_d, ",", "-append")
			varname = ["dyTDoutAd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, dy_TDout_A_d, ",", "-append")
			varname = ["dyTRAd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, dy_TR_A_d, ",", "-append")

			varname = ["rvTCAd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, rv_TC_A_d, ",", "-append")
			varname = ["rvTDinAd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, rv_TDin_A_d, ",", "-append")
			varname = ["rvTDoutAd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, rv_TDout_A_d, ",", "-append")
			varname = ["rvTRAd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, rv_TR_A_d, ",", "-append")
			varname = ["reTCAd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, re_TC_A_d, ",", "-append")
			varname = ["reTDinAd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, re_TDin_A_d, ",", "-append")
			varname = ["reTDoutAd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, re_TDout_A_d, ",", "-append")
			varname = ["reTRAd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, re_TR_A_d, ",", "-append")
			varname = ["ryTCAd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, ry_TC_A_d, ",", "-append")
			varname = ["ryTDinAd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, ry_TDin_A_d, ",", "-append")
			varname = ["ryTDoutAd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, ry_TDout_A_d, ",", "-append")
			varname = ["ryTRAd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, ry_TR_A_d, ",", "-append")

			varname = ["dvTCFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, dv_TC_F_d, ",", "-append")
			varname = ["dvTDinFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, dv_TDin_F_d, ",", "-append")
			varname = ["dvTDoutFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, dv_TDout_F_d, ",", "-append")
			varname = ["dvTRFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, dv_TR_F_d, ",", "-append")
			varname = ["deTCFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, de_TC_F_d, ",", "-append")
			varname = ["deTDinFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, de_TDin_F_d, ",", "-append")
			varname = ["deTDoutFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, de_TDout_F_d, ",", "-append")
			varname = ["deTRFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, de_TR_F_d, ",", "-append")
			varname = ["dyTCFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, dy_TC_F_d, ",", "-append")
			varname = ["dyTDinFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, dy_TDin_F_d, ",", "-append")
			varname = ["dyTDoutFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, dy_TDout_F_d, ",", "-append")
			varname = ["dyTRFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, dy_TR_F_d, ",", "-append")

			varname = ["rvTCFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, rv_TC_F_d, ",", "-append")
			varname = ["rvTDinFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, rv_TDin_F_d, ",", "-append")
			varname = ["rvTDoutFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, rv_TDout_F_d, ",", "-append")
			varname = ["rvTRFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, rv_TR_F_d, ",", "-append")
			varname = ["reTCFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, re_TC_F_d, ",", "-append")
			varname = ["reTDinFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, re_TDin_F_d, ",", "-append")
			varname = ["reTDoutFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, re_TDout_F_d, ",", "-append")
			varname = ["reTRFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, re_TR_F_d, ",", "-append")
			varname = ["ryTCFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, ry_TC_F_d, ",", "-append")
			varname = ["ryTDinFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, ry_TDin_F_d, ",", "-append")
			varname = ["ryTDoutFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, ry_TDout_F_d, ",", "-append")
			varname = ["ryTRFd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_d, varname, ",", "-append")
			dlmwrite (filename_d, ry_TR_F_d, ",", "-append")
														   
# file with baseline estimates - averages from each sample of Monte Carlo runs
			varname = ["dvTCAFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, dv_TC_AF_ave, ",", "-append")
			varname = ["dvTDinAFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, dv_TDin_AF_ave, ",", "-append")
			varname = ["dvTDoutAFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, dv_TDout_AF_ave, ",", "-append")
			varname = ["dvTRAFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, dv_TR_AF_ave, ",", "-append")
			varname = ["deTCAFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, de_TC_AF_ave, ",", "-append")
			varname = ["deTDinAFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, de_TDin_AF_ave, ",", "-append")
			varname = ["deTDoutAFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, de_TDout_AF_ave, ",", "-append")
			varname = ["deTRAFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, de_TR_AF_ave, ",", "-append")
			varname = ["dyTCAFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, dy_TC_AF_ave, ",", "-append")
			varname = ["dyTDinAFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, dy_TDin_AF_ave, ",", "-append")
			varname = ["dyTDoutAFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, dy_TDout_AF_ave, ",", "-append")
			varname = ["dyTRAFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, dy_TR_AF_ave, ",", "-append")

			varname = ["rvTCAFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, rv_TC_AF_ave, ",", "-append")
			varname = ["rvTDinAFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, rv_TDin_AF_ave, ",", "-append")
			varname = ["rvTDoutAFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, rv_TDout_AF_ave, ",", "-append")
			varname = ["rvTRAFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, rv_TR_AF_ave, ",", "-append")
			varname = ["reTCAFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, re_TC_AF_ave, ",", "-append")
			varname = ["reTDinAFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, re_TDin_AF_ave, ",", "-append")
			varname = ["reTDoutAFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, re_TDout_AF_ave, ",", "-append")
			varname = ["reTRAFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, re_TR_AF_ave, ",", "-append")
			varname = ["ryTCAFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, ry_TC_AF_ave, ",", "-append")
			varname = ["ryTDinAFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, ry_TDin_AF_ave, ",", "-append")
			varname = ["ryTDoutAFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, ry_TDout_AF_ave, ",", "-append")
			varname = ["ryTRAFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, ry_TR_AF_ave, ",", "-append")

			varname = ["dvTCAave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, dv_TC_A_ave, ",", "-append")
			varname = ["dvTDinAave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, dv_TDin_A_ave, ",", "-append")
			varname = ["dvTDoutAave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, dv_TDout_A_ave, ",", "-append")
			varname = ["dvTRAave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, dv_TR_A_ave, ",", "-append")
			varname = ["deTCAave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, de_TC_A_ave, ",", "-append")
			varname = ["deTDinAave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, de_TDin_A_ave, ",", "-append")
			varname = ["deTDoutAave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, de_TDout_A_ave, ",", "-append")
			varname = ["deTRAave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, de_TR_A_ave, ",", "-append")
			varname = ["dyTCAave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, dy_TC_A_ave, ",", "-append")
			varname = ["dyTDinAave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, dy_TDin_A_ave, ",", "-append")
			varname = ["dyTDoutAave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, dy_TDout_A_ave, ",", "-append")
			varname = ["dyTRAave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, dy_TR_A_ave, ",", "-append")

			varname = ["rvTCAave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, rv_TC_A_ave, ",", "-append")
			varname = ["rvTDinAave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, rv_TDin_A_ave, ",", "-append")
			varname = ["rvTDoutAave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, rv_TDout_A_ave, ",", "-append")
			varname = ["rvTRAave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, rv_TR_A_ave, ",", "-append")
			varname = ["reTCAave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, re_TC_A_ave, ",", "-append")
			varname = ["reTDinAave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, re_TDin_A_ave, ",", "-append")
			varname = ["reTDoutAave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, re_TDout_A_ave, ",", "-append")
			varname = ["reTRAave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, re_TR_A_ave, ",", "-append")
			varname = ["ryTCAave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, ry_TC_A_ave, ",", "-append")
			varname = ["ryTDinAave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, ry_TDin_A_ave, ",", "-append")
			varname = ["ryTDoutAave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, ry_TDout_A_ave, ",", "-append")
			varname = ["ryTRAave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, ry_TR_A_ave, ",", "-append")

			varname = ["dvTCFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, dv_TC_F_ave, ",", "-append")
			varname = ["dvTDinFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, dv_TDin_F_ave, ",", "-append")
			varname = ["dvTDoutFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, dv_TDout_F_ave, ",", "-append")
			varname = ["dvTRFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, dv_TR_F_ave, ",", "-append")
			varname = ["deTCFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, de_TC_F_ave, ",", "-append")
			varname = ["deTDinFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, de_TDin_F_ave, ",", "-append")
			varname = ["deTDoutFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, de_TDout_F_ave, ",", "-append")
			varname = ["deTRFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, de_TR_F_ave, ",", "-append")
			varname = ["dyTCFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, dy_TC_F_ave, ",", "-append")
			varname = ["dyTDinFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, dy_TDin_F_ave, ",", "-append")
			varname = ["dyTDoutFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, dy_TDout_F_ave, ",", "-append")
			varname = ["dyTRFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, dy_TR_F_ave, ",", "-append")

			varname = ["rvTCFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, rv_TC_F_ave, ",", "-append")
			varname = ["rvTDinFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, rv_TDin_F_ave, ",", "-append")
			varname = ["rvTDoutFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, rv_TDout_F_ave, ",", "-append")
			varname = ["rvTRFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, rv_TR_F_ave, ",", "-append")
			varname = ["reTCFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, re_TC_F_ave, ",", "-append")
			varname = ["reTDinFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, re_TDin_F_ave, ",", "-append")
			varname = ["reTDoutFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, re_TDout_F_ave, ",", "-append")
			varname = ["reTRFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, re_TR_F_ave, ",", "-append")
			varname = ["ryTCFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, ry_TC_F_ave, ",", "-append")
			varname = ["ryTDinFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, ry_TDin_F_ave, ",", "-append")
			varname = ["ryTDoutFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, ry_TDout_F_ave, ",", "-append")
			varname = ["ryTRFave_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_ave, varname, ",", "-append")
			dlmwrite (filename_ave, ry_TR_F_ave, ",", "-append")

# file with standard deviations of the baseline estimates - from each sample of Monte Carlo runs
			varname = ["dvTCAFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, dv_TC_AF_std, ",", "-append")
			varname = ["dvTDinAFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, dv_TDin_AF_std, ",", "-append")
			varname = ["dvTDoutAFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, dv_TDout_AF_std, ",", "-append")
			varname = ["dvTRAFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, dv_TR_AF_std, ",", "-append")
			varname = ["deTCAFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, de_TC_AF_std, ",", "-append")
			varname = ["deTDinAFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, de_TDin_AF_std, ",", "-append")
			varname = ["deTDoutAFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, de_TDout_AF_std, ",", "-append")
			varname = ["deTRAFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, de_TR_AF_std, ",", "-append")
			varname = ["dyTCAFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, dy_TC_AF_std, ",", "-append")
			varname = ["dyTDinAFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, dy_TDin_AF_std, ",", "-append")
			varname = ["dyTDoutAFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, dy_TDout_AF_std, ",", "-append")
			varname = ["dyTRAFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, dy_TR_AF_std, ",", "-append")

			varname = ["rvTCAFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, rv_TC_AF_std, ",", "-append")
			varname = ["rvTDinAFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, rv_TDin_AF_std, ",", "-append")
			varname = ["rvTDoutAFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, rv_TDout_AF_std, ",", "-append")
			varname = ["rvTRAFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, rv_TR_AF_std, ",", "-append")
			varname = ["reTCAFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, re_TC_AF_std, ",", "-append")
			varname = ["reTDinAFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, re_TDin_AF_std, ",", "-append")
			varname = ["reTDoutAFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, re_TDout_AF_std, ",", "-append")
			varname = ["reTRAFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, re_TR_AF_std, ",", "-append")
			varname = ["ryTCAFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, ry_TC_AF_std, ",", "-append")
			varname = ["ryTDinAFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, ry_TDin_AF_std, ",", "-append")
			varname = ["ryTDoutAFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, ry_TDout_AF_std, ",", "-append")
			varname = ["ryTRAFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, ry_TR_AF_std, ",", "-append")

			varname = ["dvTCAstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, dv_TC_A_std, ",", "-append")
			varname = ["dvTDinAstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, dv_TDin_A_std, ",", "-append")
			varname = ["dvTDoutAstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, dv_TDout_A_std, ",", "-append")
			varname = ["dvTRAstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, dv_TR_A_std, ",", "-append")
			varname = ["deTCAstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, de_TC_A_std, ",", "-append")
			varname = ["deTDinAstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, de_TDin_A_std, ",", "-append")
			varname = ["deTDoutAstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, de_TDout_A_std, ",", "-append")
			varname = ["deTRAstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, de_TR_A_std, ",", "-append")
			varname = ["dyTCAstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, dy_TC_A_std, ",", "-append")
			varname = ["dyTDinAstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, dy_TDin_A_std, ",", "-append")
			varname = ["dyTDoutAstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, dy_TDout_A_std, ",", "-append")
			varname = ["dyTRAstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, dy_TR_A_std, ",", "-append")

			varname = ["rvTCAstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, rv_TC_A_std, ",", "-append")
			varname = ["rvTDinAstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, rv_TDin_A_std, ",", "-append")
			varname = ["rvTDoutAstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, rv_TDout_A_std, ",", "-append")
			varname = ["rvTRAstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, rv_TR_A_std, ",", "-append")
			varname = ["reTCAstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, re_TC_A_std, ",", "-append")
			varname = ["reTDinAstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, re_TDin_A_std, ",", "-append")
			varname = ["reTDoutAstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, re_TDout_A_std, ",", "-append")
			varname = ["reTRAstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, re_TR_A_std, ",", "-append")
			varname = ["ryTCAstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, ry_TC_A_std, ",", "-append")
			varname = ["ryTDinAstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, ry_TDin_A_std, ",", "-append")
			varname = ["ryTDoutAstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, ry_TDout_A_std, ",", "-append")
			varname = ["ryTRAstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, ry_TR_A_std, ",", "-append")

			varname = ["dvTCFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, dv_TC_F_std, ",", "-append")
			varname = ["dvTDinFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, dv_TDin_F_std, ",", "-append")
			varname = ["dvTDoutFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, dv_TDout_F_std, ",", "-append")
			varname = ["dvTRFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, dv_TR_F_std, ",", "-append")
			varname = ["deTCFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, de_TC_F_std, ",", "-append")
			varname = ["deTDinFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, de_TDin_F_std, ",", "-append")
			varname = ["deTDoutFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, de_TDout_F_std, ",", "-append")
			varname = ["deTRFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, de_TR_F_std, ",", "-append")
			varname = ["dyTCFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, dy_TC_F_std, ",", "-append")
			varname = ["dyTDinFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, dy_TDin_F_std, ",", "-append")
			varname = ["dyTDoutFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, dy_TDout_F_std, ",", "-append")
			varname = ["dyTRFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, dy_TR_F_std, ",", "-append")

			varname = ["rvTCFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, rv_TC_F_std, ",", "-append")
			varname = ["rvTDinFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, rv_TDin_F_std, ",", "-append")
			varname = ["rvTDoutFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, rv_TDout_F_std, ",", "-append")
			varname = ["rvTRFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, rv_TR_F_std, ",", "-append")
			varname = ["reTCFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, re_TC_F_std, ",", "-append")
			varname = ["reTDinFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, re_TDin_F_std, ",", "-append")
			varname = ["reTDoutFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, re_TDout_F_std, ",", "-append")
			varname = ["reTRFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, re_TR_F_std, ",", "-append")
			varname = ["ryTCFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, ry_TC_F_std, ",", "-append")
			varname = ["ryTDinFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, ry_TDin_F_std, ",", "-append")
			varname = ["ryTDoutFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, ry_TDout_F_std, ",", "-append")
			varname = ["ryTRFstd_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_std, varname, ",", "-append")
			dlmwrite (filename_std, ry_TR_F_std, ",", "-append")

# file with the results of the Lilliefors test
			varname = ["dvTCAFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, dv_TC_AF_Ltest, ",", "-append")
			varname = ["dvTDinAFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, dv_TDin_AF_Ltest, ",", "-append")
			varname = ["dvTDoutAFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, dv_TDout_AF_Ltest, ",", "-append")
			varname = ["dvTRAFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, dv_TR_AF_Ltest, ",", "-append")
			varname = ["deTCAFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, de_TC_AF_Ltest, ",", "-append")
			varname = ["deTDinAFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, de_TDin_AF_Ltest, ",", "-append")
			varname = ["deTDoutAFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, de_TDout_AF_Ltest, ",", "-append")
			varname = ["deTRAFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, de_TR_AF_Ltest, ",", "-append")
			varname = ["dyTCAFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, dy_TC_AF_Ltest, ",", "-append")
			varname = ["dyTDinAFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, dy_TDin_AF_Ltest, ",", "-append")
			varname = ["dyTDoutAFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, dy_TDout_AF_Ltest, ",", "-append")
			varname = ["dyTRAFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, dy_TR_AF_Ltest, ",", "-append")

			varname = ["rvTCAFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, rv_TC_AF_Ltest, ",", "-append")
			varname = ["rvTDinAFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, rv_TDin_AF_Ltest, ",", "-append")
			varname = ["rvTDoutAFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, rv_TDout_AF_Ltest, ",", "-append")
			varname = ["rvTRAFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, rv_TR_AF_Ltest, ",", "-append")
			varname = ["reTCAFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, re_TC_AF_Ltest, ",", "-append")
			varname = ["reTDinAFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, re_TDin_AF_Ltest, ",", "-append")
			varname = ["reTDoutAFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, re_TDout_AF_Ltest, ",", "-append")
			varname = ["reTRAFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, re_TR_AF_Ltest, ",", "-append")
			varname = ["ryTCAFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, ry_TC_AF_Ltest, ",", "-append")
			varname = ["ryTDinAFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, ry_TDin_AF_Ltest, ",", "-append")
			varname = ["ryTDoutAFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, ry_TDout_AF_Ltest, ",", "-append")
			varname = ["ryTRAFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, ry_TR_AF_Ltest, ",", "-append")

			varname = ["dvTCALtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, dv_TC_A_Ltest, ",", "-append")
			varname = ["dvTDinALtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, dv_TDin_A_Ltest, ",", "-append")
			varname = ["dvTDoutALtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, dv_TDout_A_Ltest, ",", "-append")
			varname = ["dvTRALtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, dv_TR_A_Ltest, ",", "-append")
			varname = ["deTCALtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, de_TC_A_Ltest, ",", "-append")
			varname = ["deTDinALtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, de_TDin_A_Ltest, ",", "-append")
			varname = ["deTDoutALtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, de_TDout_A_Ltest, ",", "-append")
			varname = ["deTRALtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, de_TR_A_Ltest, ",", "-append")
			varname = ["dyTCALtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, dy_TC_A_Ltest, ",", "-append")
			varname = ["dyTDinALtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, dy_TDin_A_Ltest, ",", "-append")
			varname = ["dyTDoutALtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, dy_TDout_A_Ltest, ",", "-append")
			varname = ["dyTRALtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, dy_TR_A_Ltest, ",", "-append")

			varname = ["rvTCALtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, rv_TC_A_Ltest, ",", "-append")
			varname = ["rvTDinALtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, rv_TDin_A_Ltest, ",", "-append")
			varname = ["rvTDoutALtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, rv_TDout_A_Ltest, ",", "-append")
			varname = ["rvTRALtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, rv_TR_A_Ltest, ",", "-append")
			varname = ["reTCALtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, re_TC_A_Ltest, ",", "-append")
			varname = ["reTDinALtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, re_TDin_A_Ltest, ",", "-append")
			varname = ["reTDoutALtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, re_TDout_A_Ltest, ",", "-append")
			varname = ["reTRALtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, re_TR_A_Ltest, ",", "-append")
			varname = ["ryTCALtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, ry_TC_A_Ltest, ",", "-append")
			varname = ["ryTDinALtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, ry_TDin_A_Ltest, ",", "-append")
			varname = ["ryTDoutALtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, ry_TDout_A_Ltest, ",", "-append")
			varname = ["ryTRALtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, ry_TR_A_Ltest, ",", "-append")

			varname = ["dvTCFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, dv_TC_F_Ltest, ",", "-append")
			varname = ["dvTDinFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, dv_TDin_F_Ltest, ",", "-append")
			varname = ["dvTDoutFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, dv_TDout_F_Ltest, ",", "-append")
			varname = ["dvTRFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, dv_TR_F_Ltest, ",", "-append")
			varname = ["deTCFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, de_TC_F_Ltest, ",", "-append")
			varname = ["deTDinFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, de_TDin_F_Ltest, ",", "-append")
			varname = ["deTDoutFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, de_TDout_F_Ltest, ",", "-append")
			varname = ["deTRFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, de_TR_F_Ltest, ",", "-append")
			varname = ["dyTCFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, dy_TC_F_Ltest, ",", "-append")
			varname = ["dyTDinFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, dy_TDin_F_Ltest, ",", "-append")
			varname = ["dyTDoutFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, dy_TDout_F_Ltest, ",", "-append")
			varname = ["dyTRFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, dy_TR_F_Ltest, ",", "-append")

			varname = ["rvTCFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, rv_TC_F_Ltest, ",", "-append")
			varname = ["rvTDinFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, rv_TDin_F_Ltest, ",", "-append")
			varname = ["rvTDoutFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, rv_TDout_F_Ltest, ",", "-append")
			varname = ["rvTRFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, rv_TR_F_Ltest, ",", "-append")
			varname = ["reTCFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, re_TC_F_Ltest, ",", "-append")
			varname = ["reTDinFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, re_TDin_F_Ltest, ",", "-append")
			varname = ["reTDoutFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, re_TDout_F_Ltest, ",", "-append")
			varname = ["reTRFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, re_TR_F_Ltest, ",", "-append")
			varname = ["ryTCFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, ry_TC_F_Ltest, ",", "-append")
			varname = ["ryTDinFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, ry_TDin_F_Ltest, ",", "-append")
			varname = ["ryTDoutFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, ry_TDout_F_Ltest, ",", "-append")
			varname = ["ryTRFLtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_Ltest, varname, ",", "-append")
			dlmwrite (filename_Ltest, ry_TR_F_Ltest, ",", "-append")

# file with the results of the Shapiro-Wilk test
			varname = ["dvTCAFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, dv_TC_AF_SWtest, ",", "-append")
			varname = ["dvTDinAFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, dv_TDin_AF_SWtest, ",", "-append")
			varname = ["dvTDoutAFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, dv_TDout_AF_SWtest, ",", "-append")
			varname = ["dvTRAFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, dv_TR_AF_SWtest, ",", "-append")
			varname = ["deTCAFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, de_TC_AF_SWtest, ",", "-append")
			varname = ["deTDinAFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, de_TDin_AF_SWtest, ",", "-append")
			varname = ["deTDoutAFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, de_TDout_AF_SWtest, ",", "-append")
			varname = ["deTRAFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, de_TR_AF_SWtest, ",", "-append")
			varname = ["dyTCAFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, dy_TC_AF_SWtest, ",", "-append")
			varname = ["dyTDinAFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, dy_TDin_AF_SWtest, ",", "-append")
			varname = ["dyTDoutAFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, dy_TDout_AF_SWtest, ",", "-append")
			varname = ["dyTRAFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, dy_TR_AF_SWtest, ",", "-append")

			varname = ["rvTCAFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, rv_TC_AF_SWtest, ",", "-append")
			varname = ["rvTDinAFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, rv_TDin_AF_SWtest, ",", "-append")
			varname = ["rvTDoutAFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, rv_TDout_AF_SWtest, ",", "-append")
			varname = ["rvTRAFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, rv_TR_AF_SWtest, ",", "-append")
			varname = ["reTCAFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, re_TC_AF_SWtest, ",", "-append")
			varname = ["reTDinAFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, re_TDin_AF_SWtest, ",", "-append")
			varname = ["reTDoutAFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, re_TDout_AF_SWtest, ",", "-append")
			varname = ["reTRAFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, re_TR_AF_SWtest, ",", "-append")
			varname = ["ryTCAFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, ry_TC_AF_SWtest, ",", "-append")
			varname = ["ryTDinAFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, ry_TDin_AF_SWtest, ",", "-append")
			varname = ["ryTDoutAFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, ry_TDout_AF_SWtest, ",", "-append")
			varname = ["ryTRAFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, ry_TR_AF_SWtest, ",", "-append")

			varname = ["dvTCASWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, dv_TC_A_SWtest, ",", "-append")
			varname = ["dvTDinASWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, dv_TDin_A_SWtest, ",", "-append")
			varname = ["dvTDoutASWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, dv_TDout_A_SWtest, ",", "-append")
			varname = ["dvTRASWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, dv_TR_A_SWtest, ",", "-append")
			varname = ["deTCASWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, de_TC_A_SWtest, ",", "-append")
			varname = ["deTDinASWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, de_TDin_A_SWtest, ",", "-append")
			varname = ["deTDoutASWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, de_TDout_A_SWtest, ",", "-append")
			varname = ["deTRASWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, de_TR_A_SWtest, ",", "-append")
			varname = ["dyTCASWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, dy_TC_A_SWtest, ",", "-append")
			varname = ["dyTDinASWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, dy_TDin_A_SWtest, ",", "-append")
			varname = ["dyTDoutASWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, dy_TDout_A_SWtest, ",", "-append")
			varname = ["dyTRASWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, dy_TR_A_SWtest, ",", "-append")

			varname = ["rvTCASWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, rv_TC_A_SWtest, ",", "-append")
			varname = ["rvTDinASWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, rv_TDin_A_SWtest, ",", "-append")
			varname = ["rvTDoutASWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, rv_TDout_A_SWtest, ",", "-append")
			varname = ["rvTRASWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, rv_TR_A_SWtest, ",", "-append")
			varname = ["reTCASWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, re_TC_A_SWtest, ",", "-append")
			varname = ["reTDinASWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, re_TDin_A_SWtest, ",", "-append")
			varname = ["reTDoutASWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, re_TDout_A_SWtest, ",", "-append")
			varname = ["reTRASWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, re_TR_A_SWtest, ",", "-append")
			varname = ["ryTCASWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, ry_TC_A_SWtest, ",", "-append")
			varname = ["ryTDinASWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, ry_TDin_A_SWtest, ",", "-append")
			varname = ["ryTDoutASWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, ry_TDout_A_SWtest, ",", "-append")
			varname = ["ryTRASWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, ry_TR_A_SWtest, ",", "-append")

			varname = ["dvTCFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, dv_TC_F_SWtest, ",", "-append")
			varname = ["dvTDinFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, dv_TDin_F_SWtest, ",", "-append")
			varname = ["dvTDoutFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, dv_TDout_F_SWtest, ",", "-append")
			varname = ["dvTRFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, dv_TR_F_SWtest, ",", "-append")
			varname = ["deTCFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, de_TC_F_SWtest, ",", "-append")
			varname = ["deTDinFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, de_TDin_F_SWtest, ",", "-append")
			varname = ["deTDoutFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, de_TDout_F_SWtest, ",", "-append")
			varname = ["deTRFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, de_TR_F_SWtest, ",", "-append")
			varname = ["dyTCFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, dy_TC_F_SWtest, ",", "-append")
			varname = ["dyTDinFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, dy_TDin_F_SWtest, ",", "-append")
			varname = ["dyTDoutFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, dy_TDout_F_SWtest, ",", "-append")
			varname = ["dyTRFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, dy_TR_F_SWtest, ",", "-append")

			varname = ["rvTCFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, rv_TC_F_SWtest, ",", "-append")
			varname = ["rvTDinFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, rv_TDin_F_SWtest, ",", "-append")
			varname = ["rvTDoutFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, rv_TDout_F_SWtest, ",", "-append")
			varname = ["rvTRFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, rv_TR_F_SWtest, ",", "-append")
			varname = ["reTCFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, re_TC_F_SWtest, ",", "-append")
			varname = ["reTDinFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, re_TDin_F_SWtest, ",", "-append")
			varname = ["reTDoutFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, re_TDout_F_SWtest, ",", "-append")
			varname = ["reTRFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, re_TR_F_SWtest, ",", "-append")
			varname = ["ryTCFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, ry_TC_F_SWtest, ",", "-append")
			varname = ["ryTDinFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, ry_TDin_F_SWtest, ",", "-append")
			varname = ["ryTDoutFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, ry_TDout_F_SWtest, ",", "-append")
			varname = ["ryTRFSWtest_" "r" num2str(r) "s" num2str(s)];
			dlmwrite (filename_SWtest, varname, ",", "-append")
			dlmwrite (filename_SWtest, ry_TR_F_SWtest, ",", "-append")

# end the if statement for (r != s)
		endif
# end loops for r and s
	endfor
endfor

# clear all data
clear
# END of script
